
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-23
 * @see :
 */

public abstract class Activity {

    public final static int    $   = GroupRoot.$ACTIVITY$;
    public final static String _   = "ACTIVITY$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
   	                                            .lang(Language.$EN_US, "activity", "the visibility and usability")
   	                                            .lang(Language.$ZH_CN, "活性组", "表示可见性和可用性")
                                                .done();
    
    public final static int    $ACTIVE  = $ + 1;
    public final static String _ACTIVE  = "ACTIVITY$ACTIVE";
    @SystemData
    public final static Code   ACTIVE   = CodeBuilder.code($, $ACTIVE, _ACTIVE)
   	                                               .lang(Language.$EN_US, "active", "visible and usable")
   	                                               .lang(Language.$ZH_CN, "活跃的", "可见且可用")
                                                   .done();
    public final static int    $HIDDEN  = $ + 2;
    public final static String _HIDDEN  = "ACTIVITY$HIDDEN";
    @SystemData
    public final static Code   HIDDEN   = CodeBuilder.code($, $HIDDEN, _HIDDEN)
   	                                               .lang(Language.$EN_US, "hidden", "invisible and usable")
   	                                               .lang(Language.$ZH_CN, "隐藏的", "不可见但可用")
                                                   .done();
    public final static int    $FROZEN  = $ + 3;
    public final static String _FROZEN  = "ACTIVITY$FROZEN";
    @SystemData
    public final static Code   FROZEN   = CodeBuilder.code($, $FROZEN, _FROZEN)
   	                                               .lang(Language.$EN_US, "frozen", "visible and unusable")
   	                                               .lang(Language.$ZH_CN, "冻结的", "可见但不可用")
                                                   .done();
    public final static int    $ERASED  = $ + 4;
    public final static String _ERASED  = "ACTIVITY$ERASED";
    @SystemData
    public final static Code   ERASED   = CodeBuilder.code($, $ERASED, _ERASED)
   	                                               .lang(Language.$EN_US, "erased", "invisible and unusable")
   	                                               .lang(Language.$ZH_CN, "移除的", "不可见也不可用")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($ACTIVE == id) return true;
        if($HIDDEN == id) return true;
        if($FROZEN == id) return true;
        if($ERASED == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($ACTIVE == id) return ACTIVE;
        if($HIDDEN == id) return HIDDEN;
        if($FROZEN == id) return FROZEN;
        if($ERASED == id) return ERASED;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_ACTIVE.equals(key)) return ACTIVE;
        if(_HIDDEN.equals(key)) return HIDDEN;
        if(_FROZEN.equals(key)) return FROZEN;
        if(_ERASED.equals(key)) return ERASED;
        return null;
    }
}
